<template>
  <div class="page-wrap1">
    <Head title="方案信息" isBack>
      <template #content>
        <Detail
          :columns="1"
          :form="detailForm"
          :detail="data.detailData"
          :labelWidth="100"
          align="left"
        ></Detail>
      </template>
    </Head>
  </div>
</template>
 
<script lang="ts" setup>
import Head from '@/components/head/index.vue';
import Detail from '@/components/form/detail.vue';
import { queryEntrancePlan } from '@/service/apis/docking';
import { queryDicByParent } from '@/service/apis/api';

const route = useRoute();
const {
  query: { id },
} = route;

const data = reactive({
  detailData: {} as any,
});

queryDicByParent({
  listDtos: ['secondaryPricingType'],
}).then((res: any) => {
  detailForm[2].dic = [...res.secondaryPricingType];
});

const detailForm = reactive([
  {
    label: '方案名称',
    prop: 'planName',
  },
  {
    label: '提供运营商',
    prop: 'orgName',
  },
  {
    label: '二次定价类型',
    prop: 'secondaryPricingType',
    dic: [] as any,
  },
  {
    label: '电费优惠',
    prop: 'chargeDiscount',
    template: (row: any) => {
      if (row.secondaryPricingType == 1) {
        return `电费折扣${row.chargeDiscount}%`;
      } else if (row.secondaryPricingType == 2) {
        return `电费调价${row.chargeFixedDifference}元/度`;
      } else {
        return '--';
      }
    },
  },
  {
    label: '服务费优惠',
    prop: 'serviceDiscount',
    template: (row: any) => {
      if (row.secondaryPricingType == 1) {
        return `服务费折扣${row.serviceDiscount}%`;
      } else if (row.secondaryPricingType == 2) {
        return `服务费调价${row.serviceFixedDifference}元/度`;
      } else {
        return '--';
      }
    },
  },
  {
    label: '方案生效时间',
    prop: 'startTime',
    template: (row: any) => {
        return `${row.startTime}~${row.endTime}`;
    },
  },
]);

queryEntrancePlan({ id }).then((res: any) => {
  if (res) {
    data.detailData = res;
  }
});
</script>
